﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Login.ascx.cs" Inherits="Shop.Web.Controls.Login" %>
<%@ Register TagPrefix="ctrl" TagName="Registration" Src="~/Controls/Registration.ascx" %>
 <asp:PlaceHolder ID="phLogin" runat="server" Visible="false">
    <table width="100%" cellpadding="2" cellspacing="0">
        <tr>
            <td>&nbsp;</td>
            <td><a class="dialog_link" path="#register" title="Регистрация" >регистрация</a></td>
        </tr>
        <tr >
            <td align="center">e-mail</td>
            <td><asp:TextBox runat="server" ID="tbEmail" CssClass="ui-corner-all" Width=120></asp:TextBox></td>
        </tr>
        <tr>
            <td align="center">пароль</td>
            <td><asp:TextBox runat="server" ID="tbPasswrd" TextMode="Password" CssClass="ui-corner-all" Width=120></asp:TextBox></td>
        </tr>
       <%-- <tr>
            <td>&nbsp;</td>
            <td><a href="#">забыли пароль?</a></td>
        </tr>--%>
        <tr>
            <td>&nbsp;</td>
            <td><input type="checkbox" checked="checked" id="chbRemeberMe"/> запомнить меня</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td> 
            <span class="btn" onclick="Enter()">войти</span> <%--   <a href="<%= GetVkUrl() %>" onclick="VKLogin(this);return false;"><img src="http://vk.com/images/widget_logo.gif" /></a> $1$ <img src="images/Default/fb.png" />#1#--%>
            </td>
        </tr>
        </table>
        <script type="text/javascript">
            var loginWin;
       function Enter()
       {
           if ($('#<%=tbEmail.ClientID %>').val() != "" && $('#<%=tbPasswrd.ClientID %>').val() != "") {
               HideError();
               $.post("AjaxHtmlContent.aspx?Content=Login",
                   { login: $('#<%=tbEmail.ClientID %>').val(),
                       passwrd: $('#<%=tbPasswrd.ClientID %>').val(),
                       remember: $('#chbRemeberMe').get()[0].checked
                   },
                   function(data) {
                       if (data == "1") {
                           Error("Введен неправильный email или пароль.");
                       }
                       else if (data == "2") {
                           Error("Введен неправильный пароль. Ссылка для входа выслана на ваш email");
                       }
                       else {

                           $(".login").html(data);
                           $("#drft").load("AjaxHtmlContent.aspx?content=Draft");
                       }
                   }
                   );
           } else {
               Error("Введен пустой email или пароль.");
           }

       }

       function VKLogin(a) {
           loginWin = window.open(a.href, 'ВКонтакте', 'width=500,height=300'); 
           return false;
       }
       </script>
       
</asp:PlaceHolder>
<asp:PlaceHolder ID="phUser" runat="server" Visible="false">
<br/>
<table width="100%" cellpadding="2" cellspacing="0">
        <tr>
            <td>&nbsp;</td>
            <td><asp:Label ID="lblLogin" runat="server" />:<br /></td>
        </tr>
        <tr >
            <td align="center"></td>
            <td><a href="Customer.aspx">личный кабинет</a></td>
        </tr>
       <%-- <tr>
            <td align="center"></td>
            <td><a href="#">текущий заказ</a></td>
        </tr>--%>
        <tr>
            <td>&nbsp;</td>
            <td> 
                <input type="button" value="выйти" class="btn" onclick="Exit()"/>
            </td>
        </tr>
        </table>
    <script type="text/javascript">
       function Exit()
       {
            
             $.post("AjaxHtmlContent.aspx?Content=Logout", 
                   {   }, 
                   function(data){
                   $(".login").html(data);
                   $("#drft").load("AjaxHtmlContent.aspx?content=Draft");
                   } 
                   );
           
       }
       </script>
   <%-- <asp:LinkButton ID="btLogout" runat="server"  OnClick="btLogout_Click" Text="[Выйти]" />--%>
</asp:PlaceHolder>
 